<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black" />
	<meta name="format-detection" content="telephone=no" />
	<meta http-equiv="x-dns-prefetch-control" content="on" />
	<link rel="dns-prefetch" href="http://static.gtimg.com" />
	<link rel="stylesheet" type="text/css" href="{$Think.config.RESOURCEURL}wx_assets/css/product/mall.css" />
	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/alertMsg.js"></script>

	<script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/jquery-1.8.2.min.js"></script>
	<title>{$banner.name}</title>
</head>
<body>
<textarea class="J_viewData" style="display:none">{"channel":1,"page":2500,"tab":1,"wsid":2001}
</textarea>
<div class="WX_bar J_topbar">
	<div class="WX_cat J_smenu">
		<div class="WX_cat_pop WX_cat_list J_smenu_list">
		</div>
	</div>
	<div class="WX_nav">
		<a class="" href="javascript:;" id="mcTab" >{$banner.name}</a> 
	</div>
	
</div>

<!-- 地址选择 -->
<div class="WX_mask J_mask"  style="display:none;" ></div>
<!--透明遮罩层-->
<div class="WX_mask WX_mask2 J_mask_tran" style="display:none;"></div>
<div class="WX_con" id="J_main">
	
	<div class="top_ad">
	<notempty name="banner.picUrl">
		<a href="">
		<img src="{$banner.picUrl}" alt="" />
		</a>
	</notempty>
	</div>
	
	<div class="jx">
		
		<div class="jx_list" id="itemCont">
			
			
			<volist name="productList" id="product">
			
			
			<div class="jx_g" id="{$product.id}">
			
				<a  onclick="onDetail(this,{$product.id},'{$product.fixedPrice}','{$product.points}',0)" class="J_bi_product_item J_ytag" >
				<div class="jx_g_img">
                <img class="" src="{$product.picUrl}" title="{$product.name}" />
					
					<!--<div class="jx_g_rank">好评率<br><i>%</i></div>-->
				</div>
                </a>
				<div class="jx_g_info">
                
                <a  onclick="onDetail(this,{$product.id},'{$product.fixedPrice}','{$product.points}',0)" class="J_bi_product_item J_ytag" >
					<p class="jx_g_title">{$product.name}</p>
					
					<notempty name="product.title">
						<p class="jx_g_name">{$product.title}</p>
					</notempty>
					
					<notempty name="product.description">
					<p class="jx_g_promote">{$product.description}</p>
					</notempty>
					
					<if condition="($product.fixedPrice neq NULL)">
					<notempty name="product.discountedPrice">
					
						<p class="jx_g_price">
							<span class="jx_g_price_wx">
								折扣价
								<span>
								<i>&yen;</i>{$product.discountedPrice}
								</span>
							</span>
							<del class="jx_g_price_market">市场价&yen;{$product.fixedPrice}</del>
						</p>
					
		        		<p class="prices_divide">
		        		</p>
               		 </notempty>
                   	<empty name="product.discountedPrice">
		        		
		        		<p class="jx_g_price">
							<span class="jx_g_price_wx">
								市场价
								<span>
								<i>&yen;</i>{$product.fixedPrice}
								</span>
							</span>
						</p>
                   	</empty>
	             <elseif condition="($product.points neq NULL)" /> 
	                    	<p class="jx_g_price">
	                    	<if condition="$product.pointsType eq 'interact'">
			         			
			         			<span class="jx_g_price_wx">
									互动积分<span>{$product.points}</span>
								</span>
                			<elseif condition="$product.pointsType eq 'consume'"/>
			         			<span class="jx_g_price_wx">
									消费积分<span>{$product.points}</span>
								</span>
                			</if>
			         		
		        		</p>
	             <else />
                 </if>
					</a>
					 <if condition = "($showBtn eq 1)">
		      	 	  	<notempty name = "product.fixedPrice">
		      	 	  		<a class="WX_btn jx_g_btn J_bi_product_item J_ytag"  onclick="onDetail(this,{$product.id},'{$product.fixedPrice}','{$product.points}',1)">立即购买</a>
		               	</notempty>
		               	<notempty name = "product.points">
		               		<a class="WX_btn jx_g_btn J_bi_product_item J_ytag" onclick="onDetail(this,{$product.id},'{$product.fixedPrice}','{$product.points}',1)">立即兑换</a>
		               	</notempty>
	      	 	 	</if>
				</div>
				<!-- 
					<div class="WX_operate">
						<div class="WX_sns">
							<a href="javascript:void(0);" class="WX_sns_comment J_bi_product_comment J_ytag" ytag="20006" data-DAP="" data-pid="1736332">0</a>
						</div>
					</div>
				
				 -->

				<div name="time" timeNum="{$product.fixedPrice}" style="text-align: center;margin-left: auto;margin-right: auto;border:1px solid #dedede;-moz-border-radius: 15px;-webkit-border-radius: 15px;border-radius:15px;background:#dedede ">

				</div>
			
			</volist>
			
		</div>
		
		<div class="jx_map">
			<div class="load-more" id="load-more">加载更多</div>
		</div>
		
	</div>
</div>

<script>
var hrefParamsArray = GetSessionIdFromHref(window.location.search);
hrefParamsArray["userName"]='{$userName}';
countdown();
function GetSessionIdFromHref(search){
　　	var args = search.substring(1); 
　　	var retval = new Array(); 
	args = args.split("&"); 
		for(var i = 0; i < args.length; i ++){ 
			str = args[i]; 
			var arg = str.split("="); 
			if(arg.length <= 1) continue; 
			
			if(arg[0] == 'params') {
				var params = decodeURIComponent(arg[1]);
				var obj = eval('(' + params + ')');
				if (obj.rootid != undefined) {
					retval["rootid"] = obj.rootid;
				}
				if (obj.start != undefined) {
					retval["start"] = obj.start;
				}
				retval["id"] = obj.id;
			} else if(arg[0] == 'customerId') {
				retval["customerId"] = arg[1]; 
			}else if(arg[0] == 'userName'){
				retval["userName"] = arg[1]; 
			} else if(arg[0] == 'method') {
				retval["method"] = arg[1];
			} else if (arg[0] == 'module') {
				retval["module"] = arg[1];
			}
		} 
		
		if (retval["start"] == undefined) {
			retval["start"] = 0;
		}
		return retval; 
}

function onDetail(ctrl,id,fixedPrice,points,allowOrder) {
	var showBtn = {$showBtn};
	
	if(showBtn == 1){
		
		if(fixedPrice > 0 || points > 0 ){
			//TODO::judge size/color then goto different html
			// To order detail html or product detail html
	
			var rootid = '';
			if (hrefParamsArray["rootid"] !== undefined) {
				rootid = ',"rootid":' + hrefParamsArray["rootid"];
			}
			ctrl.href = 'call.html?userName=' + hrefParamsArray['userName'] + '&customerId='
			+ hrefParamsArray['customerId'] + '&module=product&method=getProduct&params={"allowOrder":'+ allowOrder + ',"tplid":2,"id":"' + id + rootid  + '"}';
			}
		}
}
function countdown(){
	$("div[name='time']").each(function(){
		var time = parseInt($(this).attr("timeNum"));
		time--;
		if(time<0){
			$(this).attr("timeNum",0);
			$(this).text("已售罄！");
		}else{
			$(this).attr("timeNum",time);
			$(this).text(formatTime(time));
		}

	});
	setTimeout(countdown,1000);
}
function formatTime(time){
	var d = parseInt(time/60/60/24);
	time-=d*24*60*60;
	var h = parseInt(time/60/60);
	time-=h*60*60;
	var m = parseInt(time/60);
	time-=m*60;
	var s = parseInt(time);
	return d+"天 "+h+"时"+m+"分"+s+"秒";
}
</script>


<script type="text/javascript" src="wx_assets/js/zepto.1.1.3.min.js?t=20140213"></script>
<script>window["PP.mobile.temaiV3.time"]=[new Date()]</script>
<script id="legos:21974" ver="21974:20140311:20140317142518" name="PP.mobile.temaiV3" src="wx_assets/js/pp.mobile.temaiV3.20140311.js?t=201403191" charset="gbk"></script><!--[if !IE]>|xGv00|928a8a491c10a489996651b9222fdc1b<![endif]-->


<script type="text/javascript">
	var LIMIT = 10;
	var start = hrefParamsArray["start"];
	var showBtn = {$showBtn};
	//var showBtn = 1;
	if ({$total} > LIMIT) {
		
		var loadNode = $("#load-more");
		loadNode.html("点击加载更多").show();
		
		loadNode.on("click",function() {
			var rootid = '';
			if (hrefParamsArray["rootid"] !== undefined) {
				rootid = ',"rootid":' + hrefParamsArray["rootid"];
			}
			
			var baseUrl =  '{$Think.config.SERVER_HOST}';
			var urlString = baseUrl + 'call.json?customerId='+ hrefParamsArray["customerId"]+'&userName='+hrefParamsArray["userName"];
			var id = {$banner.id};
			start = start +LIMIT ;
			var container = $("#itemCont");
			$.ajax({url : urlString,
						dataType : "json",
						type : "post",
						data : {
							'module': hrefParamsArray["module"],
					        'method' : hrefParamsArray["method"],
					        'params' : '{"tplid":1,"id":' + hrefParamsArray["id"] + ',"start":' + start + rootid + '}',
						},
						success : function(data) {
							if (data.code != undefined) {
								alert(data.msg);
								return;
							}

							if ({$total} <= start + LIMIT) {
								loadNode.hide();
							}
							var productList = data['productList'];
	      	                var str = '';
	      	                
	      	                for(key in productList) {
	      	                	var product = productList[key];
	      	                	
	      	                	
	      	                	var priceStr = '';
	      	                	var titStr = '';
	      	                	var desStr = '';
	      	                	
	      	                	if(product["title"] !=null && product["title"] != ""){
	      	                		titStr = "<p class='jx_g_name'>"+product["title"]+"</p>";
	      	                	}
	      	                	
								if(product["description"] !=null && product["description"] != ""){
						      		desStr = "<p class='jx_g_promote'>"+product["description"]+"</p>";
						      	}
  	        	 			
	      	                	
	      	                	if(product["discountedPrice"] != null && product["fixedPrice"] != null ){
	      	                		priceStr = "<p class='jx_g_price'> <span class='jx_g_price_wx'>折扣价<span><i>&yen;</i>"
	      	                		+product["discountedPrice"]
	      	                		+"元</span></span><del class='jx_g_price_market'>市场价￥"+product["fixedPrice"]+"</del> <p class='prices_divide'></p>";
	      	                		
	      	                	}else if(product["fixedPrice"] != null && product["discountedPrice"] == null){
	      	                		priceStr = "<p class='jx_g_price'><span class='jx_g_price_wx'>市场价<span><i>￥</i>"+product["fixedPrice"]+"</span></span></p>";
	      	                		
	      	                	}else if(product["points"] != null && product["pointsType"] == 'interact'){
	      	                		priceStr = "<p class='jx_g_price'> <span class='jx_g_price_wx'>互动积分<span>"+product["points"]+"</span> 积分</span> </p>";
	      	                		
	      	                	}else if(product["points"] != null && product["pointsType"] == 'consume'){
	      	                		priceStr = "<p class='jx_g_price'> <span class='jx_g_price_wx'>消费积分<span>"+product["points"]+"</span> 积分</span> </p>";
	      	                	
	      	                	}
	      	                	
	      	                	var btnStr = '';
	      	                	
	      	                	if(showBtn == 1){
	      	                		
		      	                	if(product["fixedPrice"] != null ){
		      	                		btnStr= "<a class='WX_btn jx_g_btn J_bi_product_item J_ytag' onclick='onDetail(this,"+product["id"]+ ","+ product["fixedPrice"] + "," + product["points"] + ",1" + ")'>立即购买</a>";
		      	                	}else if(product["points"] != null){
		      	                		btnStr= "<a class='WX_btn jx_g_btn J_bi_product_item J_ytag' onclick='onDetail(this,"+product["id"]+ ","+ product["fixedPrice"] + "," + product["points"] + ",1" + ")'>立即兑换</a>";
		      	                	}
		      	                	
	      	                	}
	      	                	
	      	                	str += "<div class='jx_g' id='"+product["id"]+"'>"
								+"<a onclick='onDetail(this,"+product["id"]+ ","+ product["fixedPrice"] + "," + product["points"] + ",0" + ")' class='J_bi_product_item J_ytag'>"
	      	                			+"<div class='jx_g_img'>"
										+"<img  class='' title='"+product["name"]+"' src='"+product["picUrl"]+"'> "
		      	        	 			+"</div>"
										+"</a>"
		      	        	 			+"<div class='jx_g_info'>"
										+"<a onclick='onDetail(this,"+product["id"]+ ","+ product["fixedPrice"] + "," + product["points"] + ",0" + " )' class='J_bi_product_item J_ytag'>"
		      	        	 			+"<p class='jx_g_title'>"+product["name"]+"</p>"
		      	        	 			+titStr
		      	        	 			+desStr
	      	      	 					+priceStr
	      	      	 					+btnStr
	      	      	 					+"</div>"
	      	      	 					+"</div>";
	      	      	 					
	      	                }
	      	                container[0].innerHTML += str;
						}
				});
		});	
	}else{
		$("#load-more").hide();
	}
</script>

<script>
	(function() {
		function formatV(v, split) {
			if (v == null) {
				return;
			}
			split = split || '.';
			var f = v.split(split);
			f = f.shift() + '.' + f.join('');
			return parseFloat(f);
		}
		$.os.fVersion = formatV($.os.version);

		var tag = '';
		if ($.os.ios) {
			tag = 'ios' + $.os.version.replace(/\./g, '_');
			if ($.os.fVersion < 6) {
				tag += ' lowIphone';
			} else {
				tag += ' scrollLayout';
			}
		} else if ($.os.android) {
			tag = 'android' + $.os.version.replace(/\./g, '_');
			if ($.os.fVersion < 4) {
				tag += ' lowAndroid';
			} else {
				tag += ' fixedLayout';
			}
		}
		if (tag) {
			$('html').addClass(tag);
		}
	})();
</script>

<script type="text/javascript">
function resetAndAppendHerf(search){
　　	var args = search.substring(1); 
　　	var retval = new Array(); 
	args = args.split("&"); 
	for(var i = 0; i < args.length; i ++){ 
		str = args[i]; 
		var arg = str.split("="); 
		if(arg.length <= 1) continue; 
		if(arg[0] == 'userName'){
			args[i] = "userName=";
		}
	} 
	return args.join("&");
}

$(function(){
	var imageUrl = '{$productList[0].picUrl}';
	var title = '{$productList[0].name}';
	var des = '点击这里查看商品';
	var search = '?' + resetAndAppendHerf(window.location.search);
	var shareUrlString = window.location.protocol + "//"
			+ window.location.host + window.location.pathname + search;	      
	
	window.shareData = {
		"imgUrl": imageUrl,
		"timeLineLink":  shareUrlString ,
		"sendFriendLink":  shareUrlString ,
		"weiboLink":  shareUrlString ,
		"tTitle": title,
		"tContent": des,
		"fTitle": title,
		"fContent": des,
		"wContent": des
	};
	document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
		// 发送给好友
		WeixinJSBridge.on('menu:share:appmessage', function (argv) {
			WeixinJSBridge.invoke('sendAppMessage', {
				"img_url":  window.shareData.imgUrl,
				"img_width": "640",
				"img_height": "640",
				"link": window.shareData.sendFriendLink,
				"desc": window.shareData.fContent,
				"title": window.shareData.fTitle
			}, function (res) {
				_report('send_msg', res.err_msg);
			})
		});
	
		// 分享到朋友圈
		WeixinJSBridge.on('menu:share:timeline', function (argv) {
			WeixinJSBridge.invoke('shareTimeline', {
				"img_url": window.shareData.imgUrl,
				"img_width": "640",
				"img_height": "640",
				"link": window.shareData.timeLineLink,
				"desc": window.shareData.tContent,
				"title": window.shareData.tTitle
			}, function (res) {
				_report('timeline', res.err_msg);
			});
		});
	
		// 分享到微博
		WeixinJSBridge.on('menu:share:weibo', function (argv) {
			WeixinJSBridge.invoke('shareWeibo', {
				"content": window.shareData.wContent,
				"url": window.shareData.weiboLink
			}, function (res) {
				_report('weibo', res.err_msg);
			});
		});
	});
});
</script>

</body>
</html>
